package com.gateway.security.common.authorization;

import com.gateway.common.dto.ApiDefinition;
import org.springframework.security.authorization.AuthorizationDecision;
import org.springframework.security.core.Authentication;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @program: api-gateway
 * @description:
 * @author: YuKai Fan
 * @create: 2025/2/11 22:47
 **/
public class NoAuthorizationChecker implements AuthorizationChecker {

    private static final AuthorizationChecker INSTANCE = new NoAuthorizationChecker();

    private NoAuthorizationChecker() {
    }

    public static AuthorizationChecker getInstance() {
        return INSTANCE;
    }

    @Override
    public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, ServerWebExchange exchange, ApiDefinition apiDefinition) {
        // 不做任何鉴权，直接通过
        return Mono.just(new AuthorizationDecision(true));
    }
}
